<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no">
    <meta name="format-detection" content="telephone=no">
    <title>登录</title>
    <link href="__ROOT__/Public/favicon.ico" type="image/x-icon" rel="shortcut icon">
    <link rel="stylesheet" href="__CSS__/frozen.css">
    <script src="__LIB__/zepto.min.js"></script>
    <script src="__JS__/frozen.js"></script>
    <link rel="stylesheet" href="__CSS__/demo.css">
</head>

<body ontouchstart>

<section class="ui-container" style="margin-top: 40px;">

    <section id="form" >
        <section class="ui-container ui-center">
            <img src="__ROOT__/Public/logo.png">
        </section>

        <div class="demo-item">
            <p class="demo-desc">用户登录</p>
            <div class="demo-block">
                <div class="ui-form ui-border-t">
                    <form action="#">
                        <div class="ui-form-item ui-form-item-show ui-border-b">
                            <label for="username">手机号</label>
                            <input type="text" id="username" placeholder="请输入手机号">
                        </div>
                        <div class="ui-form-item ui-form-item-show ui-border-b">
                            <label for="password">密 码</label>
                            <input type="password" id="password" placeholder="请输入密码">
                        </div>
                    </form>
                </div>
            </div>
        </div>

        <div class="ui-btn-wrap" style="margin-top: 16%">
            <button class="ui-btn-lg ui-btn-primary" onclick="sub_login()">
                登录
            </button>
        </div>

    </section>

</section><!-- /.ui-container-->

<script type="text/javascript">
    
    //提交登录
    function sub_login() {
        var username = $('#username').val();
        var password = $("#password").val();
        if(username==''){
            tip('请输入账号!');
            $('#username').focus();
            return;
        }
        if(password==""){
            tip('请输入密码!');
            $('#password').focus();
            return;
        }

        $.ajax({
            type: "post",
            url: "{:U('checkLogin')}",
            data: "username=" + username + "&password=" + password,
            success: function (result) {
                if (result.status == 1) {
                    ok(result.info, result.url);
                } else {
                    tip(result.info);
                }
            }
        });
    }

    //ok
    function ok(msg, url) {
        var el;
        el = $.tips({
            content: msg,
            stayTime: 1000,
            type: "success"
        })
        el.on("tips:hide", function () {
            //跳转
            console.log("tips hide");
            window.location.href = url;
        })
    }

    function tip(msg) {
        var el3;
        el3 = $.tips({
            content: msg,
            stayTime: 2000,
            type: "warn"
        })
        el3.on("tips:hide", function () {
            console.log("tips hide");
        })
    }

</script>

</body>
</html>